package com.xqboss.apps.dto.market;

import com.xqboss.apps.dto.PageDto;
import com.xqboss.apps.enums.market.MarketStatusEnum;
import com.xqboss.apps.enums.market.MarketTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Objects;

/**
 * <p>
 *     市场列表(扩展)参数
 * </p>
 * @author Trent
 * @date 2023/8/24
 */
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel
public class MarketResellDto extends PageDto {

    @ApiModelProperty(value = "市场类型",required = true)
    @NotNull(message = "请输入市场类型")
    private MarketTypeEnum type;

    @ApiModelProperty(value = "用户id(app不用传)")
    private Long userId;

    @ApiModelProperty(value = "搜索(app不用传)")
    private String search;
    @ApiModelProperty("开始时间(app不用传)")
    private LocalDateTime createTimeStart;
    @ApiModelProperty("结束时间(app不用传)")
    private LocalDateTime createTimeEnd;

    @NotNull(message = "请输入市场状态")
    private MarketStatusEnum status;

    @ApiModelProperty("源id,除了材料其他不传.热豆 2 扳手10 ")
    private Long sourceId;

    public LocalDateTime getCreateTimeEnd() {
        if(Objects.nonNull(createTimeEnd)){
            return createTimeEnd.with(LocalTime.MAX);
        }
        return createTimeEnd;
    }
}
